package com.zego.wawaji.ui.bean.wawa;

import android.os.Parcel;
import android.os.Parcelable;

import com.zego.wawaji.base.data.BaseData;

import org.json.JSONArray;

import java.util.ArrayList;
import java.util.List;

/**
 * 娃娃机列表
 * Created by Su on 2017/11/28.
 */
public class WawaJiList extends BaseData implements Parcelable {
    private List<WawaJi> wawaList = new ArrayList<>();
    private List<WawaJi> wawaShowList = new ArrayList<>();

    @Override
    public void parseJson(String jsonStr) {
        JSONArray jsonArray = getJsonArray(jsonStr);
        this.wawaList = (List<WawaJi>) getBaseDataList(jsonArray, WawaJi.class);
    }

    public List<WawaJi> getWawaJiShowList() {
        for (int i = 0; i < wawaList.size(); i++) {
            if (wawaList.get(i).getStatus() != -3) {
                wawaShowList.add(wawaList.get(i));
            }
        }
        return wawaShowList;
    }

    public List<WawaJi> getWawaJiList() {
        return wawaList;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeTypedList(this.wawaList);
        dest.writeTypedList(this.wawaShowList);
    }

    public WawaJiList() {
    }

    protected WawaJiList(Parcel in) {
        this.wawaList = in.createTypedArrayList(WawaJi.CREATOR);
        this.wawaShowList = in.createTypedArrayList(WawaJi.CREATOR);
    }

    public static final Creator<WawaJiList> CREATOR = new Creator<WawaJiList>() {
        @Override
        public WawaJiList createFromParcel(Parcel source) {
            return new WawaJiList(source);
        }

        @Override
        public WawaJiList[] newArray(int size) {
            return new WawaJiList[size];
        }
    };
}
